////////////////////////////////////////////////////////////////////////////////
//
//  nino
//
////////////////////////////////////////////////////////////////////////////////

package ochart.utils.logging
{
	public class Level extends Priority
	{
		public static const DEBUG:Level = new Level(DEBUG_INT);
		
		public static const INFO:Level = new Level(INFO_INT);
		
		public static const WARN:Level = new Level(WARN_INT);
		
		public static const ERROR:Level = new Level(ERROR_INT);
		
		public static const FATAL:Level = new Level(FATAL_INT);
		
		public function Level(level:int)
		{
			super(level);
		}
		
		public static function intToLevel(value:int):Level
		{
			switch(value)
			{
				case FATAL_INT:
					return FATAL;
				case ERROR_INT:
					return ERROR;
				case WARN_INT:
					return WARN;
				case INFO_INT:
					return INFO;
				case DEBUG_INT:
					return DEBUG;
			}
			return null;
		}
		
		public static function stringToLevel(value:String):Level
		{
			switch(value)
			{
				case FATAL_STRING:
					return FATAL;
				case ERROR_STRING:
					return ERROR;
				case WARN_STRING:
					return WARN;
				case INFO_STRING:
					return INFO;
				case DEBUG_STRING:
					return DEBUG;
			}
			return null;
		}
		
		public static function getEqualAndGreaterLevelArray(level:Level):Array
		{
			if(!level)
			{
				return null;
			}
			
			var array:Array = [];
			if(level.level >= DEBUG_INT)
			{
				array.push(Level.DEBUG);
			}
			if(level.level >= INFO_INT)
			{
				array.push(Level.INFO);
			}
			if(level.level >= WARN_INT)
			{
				array.push(Level.WARN);
			}
			if(level.level >= ERROR_INT)
			{
				array.push(Level.ERROR);
			}
			if(level.level >= FATAL_INT)
			{
				array.push(Level.FATAL);
			}
			return array;
		}
		
		public static function getLessLevelArray(level:Level):Array
		{
			if(!level)
			{
				return null;
			}
			
			var array:Array = [];
			if(level.level < DEBUG_INT)
			{
				array.push(Level.DEBUG);
			}
			if(level.level < INFO_INT)
			{
				array.push(Level.INFO);
			}
			if(level.level < WARN_INT)
			{
				array.push(Level.WARN);
			}
			if(level.level < ERROR_INT)
			{
				array.push(Level.ERROR);
			}
			if(level.level < FATAL_INT)
			{
				array.push(Level.FATAL);
			}
			return array;
		}
	}
}